package service

import (
	"encoding/json"
	"zsc-boot/app/system_layer/model"
	"zsc-boot/core/orm"
)

func GetDictByKey[T any](key string) (res T, err error) {
	var data model.Dictionary
	if err = orm.GetDb().Where("`key` = ?", key).First(&data).Error; err != nil {
		return
	}

	err = json.Unmarshal(data.Value, &res)
	return
}
